<div class="layui-card-body" style="line-height: 36px;font-size: 14px;">
    <style>.layui-layer-content{height: 650px  }</style>
    <div class="layui-row margin-bottom-12">
        <label class="layui-col-xs4 think-form-label">计划编号：{$info.id}</label>
        <label class="layui-col-xs2"></label>
        <label class="layui-col-xs4 think-form-label">计划名称：{$info.plan_title}</label>
        <label class="layui-col-xs2"></label>
        <label class="layui-col-xs4 think-form-label">计划类型：{$info.plan_type==0?'临时计划':'月计划'}</label>
    </div>
    <div class="layui-row margin-bottom-15">
    </div>
    <div class="layui-row margin-bottom-12">
        <label class="layui-col-xs4 think-form-label">申报时间：{$info.create_at|default=''}</label>
        <label class="layui-col-xs2"></label>
        <label class="layui-col-xs4 think-form-label">申报人：{$info.admin_name|default=''}</label>
    </div>
    <div class="layui-row margin-bottom-15">
    </div>
    <div class="layui-row margin-bottom-15">
        {if $info.status eq -1}
        <label class="layui-col-xs4 think-form-label">拒绝原因：{$info.to_reason|default=''}</label>
        <label class="layui-col-xs2"></label>
        {/if}
        <label class="layui-col-xs4 think-form-label" style="color: red">当前流程：{if $info.plan_status eq 2}计划已提交，物流配送中心---{/if}
            {if $info.plan_status eq 3}物流配送中心已通过，业务科室---{/if}
            {if $info.plan_status eq 4}业务科室已通过，精益化管理部---{/if}
            {if $info.status eq 0}审核中{/if}
            {if $info.status eq 1}已通过{/if}
            {if $info.status eq -1}已拒绝{/if}</label>
    </div>
    <div class="layui-row margin-bottom-12">
        <button id="btn" class="layui-btn" type='submit' style="float: right;">导  出</button>
    </div>
    <div class="layui-row margin-bottom-15">
        <table class="layui-table margin-top-10 table2excel" lay-skin="line" id='dataInfo' lay-filter="demo">
            <thead>
            <tr>
                <th class="text-center">编号</th>
                <th class="text-center">名称</th>
                <th class="text-center">型号</th>
                <th class="text-center">单位</th>
                <th class="text-center">价格</th>
                <th class="text-center">数量</th>
                <th class="text-center">金额</th>
                <!--{if $info.status neq 1}-->
                <!--<th class="text-center">备注</th>-->
                <!--{/if}-->
                <!--<th class="text-center">操作</th>-->
            </tr>
            </thead>
            <tbody id="one_add">
            <style>
                th{text-align: center;}
                .burds{width:80%;height:28px;text-align: center;border: none;}
                .layui-layer-page{width: 80% !important;}
            </style>
            {foreach $plan_list as $k=>$v}
            <tr>

                <td class='text-center'>{$v.material_code|default=''}</td>
                <td class='text-center'>{$v.material_name|default=''}</td>
                <td class='text-center'>{$v.material_model|default=''}</td>
                <td class='text-center'>{$v.material_unit|default=''}</td>
                {if $info.status eq 1}
                <td class='text-center material_price'>{$v.material_price|default=''}</td>
                <td class='text-center'>{$v.material_num|default=''}</td>
                <td class='text-center'><span class="material_xjprice">{$v.material_xjprice|default=''}</span></td>
                <!--<td class='text-center buttoms' style="font-size:12px">-->
                <!--    <a data-title="日志" data-dbclick class="layui-btn layui-btn-sm" data-modal='{:url("detail_log")}?id={$v.id}' style="font-size:12px">日志</a>-->
                <!--</td>-->
                {else /}
                <td class='text-center material_price'>
                    <input style='border:none;height:28px;text-align: center;width:80px' value="{$v.material_price|default=''}" readonly>
                </td>
                <td class='text-center'><input class="burds numbers" readonly type="number" placeholder="数量" value="{$v.material_num|default=''}" data-id="{$v.id}" /></td>
                <td class='text-center'><span class="material_xjprice">{$v.material_xjprice|default=''}</span></td>
                <!--<td class='text-center'><input readonly class="burds remarks" type="text" placeholder="备注" value="{$v.remarks|default=''}" data-id="{$v.id}" /></td>-->
                <!--<td class='text-center buttoms' style="font-size:12px">-->
                <!--    <button class="preserve" style="padding: 4px 2px" data-num="" data-remarks="" data-id="{$v.id}" data-confirm="确定要保存吗？">保存</button>&nbsp;&nbsp;&nbsp;-->
                <!--    <a data-title="日志" data-dbclick class="layui-btn layui-btn-sm" data-modal='{:url("detail_log")}?id={$v.id}' style="font-size:12px">日志</a>-->
                <!--</td>-->
                {/if}
            </tr>
            {/foreach}
            <tr>
                <td class='text-center'>总计</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td class='text-center' id="total">{$total}</td>
                <!--<td></td>-->
                <!--<td></td>-->
            </tr>
            </tbody>
        </table>
    </div>
</div>
<div class="hr-line-dashed"></div>
<div class="layui-form-item text-center">
    <button class="layui-btn layui-layer-close layui-layer-close1" type='submit'>关闭</button>
</div>
<script>
    $(function() {
        $("#btn").click(function(){
            $(".table2excel").table2excel({
                exclude: ".noExl",
                name: "1111",
                filename: "{$info.admin_name}"+"{$info.plan_title}",
                exclude_img: true,
                exclude_links: true,
                exclude_inputs: true
            });
        });
    });
    $('.remarks').bind("input propertychange",function(){
        var that = $(this).parent().siblings(".buttoms").find('.preserve')
        that.attr("data-remarks",$(this).val());
    });
    $('.numbers').bind("input propertychange",function(){
        var that = $(this).parent().siblings(".buttoms").find('.preserve')
        that.attr("data-num",$(this).val());
        var price = $(this).parent().siblings(".material_price").find('input').val() * $(this).val()
        $(this).parent().next().find('span').text(price.toFixed(2))
    });
    $('.preserve').click(function () {
        var num = $(this).context.dataset.num
        var remarks = $(this).context.dataset.remarks
        if(remarks == ''){return alert('备注不可为空');}
        var index = $(this).data('id')
        var id = "{$info['id']}"
        var aaa = $(this)
        $.ajax({
            type: 'POST',
            url: "{:url('remarks')}",
            data: {
                index: index,
                id: id,
                numbers: num,
                remarks:remarks
            },
            dataType: "json",
            success: function (data) {
                console.log(data)
                if(data.code == 200){
                    alert('数据已更新,请点击日志查看')
                    $('.remarks').val('')
                }else{
                    alert(data.msg)
                }
            }
        });
    });
</script>
<script src="__ROOT__/static/jquery.table2excel.js"></script>